<?php
	session_start();	
	
    require_once "loginview.php";
	require_once "loginHandler.php";
	
	$title = "FRIDA LOGIN";
	$body = "<h1>Login / Frida</h1>";
	
	 		$lw = new LoginView();
		$lh = new LoginHandler();
		$body .= $lw->DoLoginBox();

		if ($lw->TriedToLogin() ) {
			
			$name = $lw->GetUserName();
			$password = $lw->GetPassword();
			
			if ($lh->DoLogin($name, $password) == true) {
				$body .= "<p>" . $name . " and password " . $password . " is logged in!" . "</p>";
				$body .= $lw->DoLogoutBox();
				$loggedInName = $name;
			} else {
				$body .= "<p>Allready logged in / wrong username or password  </p>"; //insert inlogged users name
				$body .= $lw->DoLogoutBox();
			}	
			
		} else {
		  	$body .= "<p>" . "Not logged in! <br />" . "</p>"; 
		}
		

		if ($lw->TriedToLogout() ) {
			$lh->DoLogout();
		  	$body .= "<p>User has logged out!</p>";
		}

		
		$lh->Test();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title><?php echo $title; ?></title>
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="style.css" media="screen" type="text/css">	
  </head>
  <body class="">
  <div id="wrapper">
  	<?php 
		echo $body;
	?>
   </div>
  </body>
</html>

